package com.example.papercut.controller;

import com.example.papercut.entity.dimension.*;
import com.example.papercut.service.dimension.DimensionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/api/dimensions")
public class DimensionController {

    // 注入所有维度 Service
    @Autowired private DimensionService<PCCategory> categoryService;
    @Autowired private DimensionService<PCTheme> themeService;
    @Autowired private DimensionService<PCTechnique> techniqueService;
    @Autowired private DimensionService<PCLayout> layoutService;
    @Autowired private DimensionService<AuthorStyle> authorStyleService; // 假设您也创建了 AuthorStyleService
    @Autowired private DimensionService<TXTCategory> textureCategoryService; // <-- 新增注入

    /**
     * GET /api/dimensions/categories (剪纸分类)
     */
    @GetMapping("/categories")
    public ResponseEntity<List<PCCategory>> getAllCategories() {
        return ResponseEntity.ok(categoryService.findAll());
    }

    /**
     * GET /api/dimensions/themes (剪纸主题)
     */
    @GetMapping("/themes")
    public ResponseEntity<List<PCTheme>> getAllThemes() {
        return ResponseEntity.ok(themeService.findAll());
    }

    /**
     * GET /api/dimensions/techniques (剪纸技法)
     */
    @GetMapping("/techniques")
    public ResponseEntity<List<PCTechnique>> getAllTechniques() {
        return ResponseEntity.ok(techniqueService.findAll());
    }

    /**
     * GET /api/dimensions/layouts (剪纸布局)
     */
    @GetMapping("/layouts")
    public ResponseEntity<List<PCLayout>> getAllLayouts() {
        return ResponseEntity.ok(layoutService.findAll());
    }

    /**
     * GET /api/dimensions/author-styles (作者派系)
     */
    @GetMapping("/author-styles")
    public ResponseEntity<List<AuthorStyle>> getAllAuthorStyles() {
        return ResponseEntity.ok(authorStyleService.findAll());
    }

    /**
     * GET /api/dimensions/texture-categories (纹理分类)
     */
    @GetMapping("/texture-categories") // <-- 新增接口
    public ResponseEntity<List<TXTCategory>> getAllTextureCategories() {
        return ResponseEntity.ok(textureCategoryService.findAll());
    }

}